import 'package:aihu_getx_app/app/modules/commons/commons.dart';
import 'package:aihu_getx_app/utils/constants.dart';
import 'package:aihu_getx_app/utils/init_system_data_util.dart';
import 'package:aihu_getx_app/widgets/common_image.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../controllers/d_my_profile_detail_controller.dart';

class DMyProfileDetailView extends GetView<DMyProfileDetailController> {
  const DMyProfileDetailView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: Commons.appBar(
        title: controller.title,
        subTitle: controller.appName.value,
        refresh: controller.onRefresh,
      ),
      body: Container(
        color: Colors.white,
        width: Get.width,
        height: Get.height,
        padding: const EdgeInsets.all(10),
        child: Obx(
          () => RefreshIndicator(
            color: Get.theme.primaryColorLight,
            backgroundColor: Get.theme.primaryColor,
            onRefresh: controller.onRefresh,
            child: ListView(
              children: [
                GestureDetector(
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                    ),
                    child: Row(
                      children: [
                        const Icon(Icons.image_search),
                        const SizedBox(width: 10),
                        Text(
                          '头像',
                          style: Get.textTheme.titleMedium,
                        ),
                        Expanded(
                          child: Align(
                            alignment: Alignment.centerRight,
                            child: CommonImage(
                              GetUtils.isNullOrBlank(
                                      controller.userProfile.value.avatar)!
                                  ? Constants.icon
                                  : controller.userProfile.value.avatar,
                              isCircle: true,
                              width: 60,
                              height: 60,
                            ),
                          ),
                        ),
                        const SizedBox(width: 20),
                        const Icon(
                          Icons.keyboard_arrow_right,
                        )
                      ],
                    ),
                  ),
                  onTap: () => print("ttttttttt"),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
                GestureDetector(
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                    ),
                    child: Row(
                      children: [
                        const Icon(Icons.perm_identity),
                        const SizedBox(width: 10),
                        Text(
                          '用户名称',
                          style: Get.textTheme.titleMedium,
                        ),
                        Expanded(
                          child: Align(
                            alignment: Alignment.centerRight,
                            child: Text(
                              '${controller.userProfile.value.username}',
                              style: Get.textTheme.bodyMedium,
                            ),
                          ),
                        ),
                        // const SizedBox(width: 20),
                        const Icon(null //Icons.keyboard_arrow_right,
                            )
                      ],
                    ),
                  ),
                  //onTap: () => print("ttttttttt"),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
                GestureDetector(
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                    ),
                    child: Row(
                      children: [
                        const Icon(Icons.nightlife),
                        const SizedBox(width: 10),
                        Text(
                          '用户昵称',
                          style: Get.textTheme.titleMedium,
                        ),
                        Expanded(
                          child: Align(
                            alignment: Alignment.centerRight,
                            child: Text(
                              '${controller.userProfile.value.nickname}',
                              style: Get.textTheme.bodyMedium,
                            ),
                          ),
                        ),
                        // const SizedBox(width: 20),
                        const Icon(
                          Icons.keyboard_arrow_right,
                        )
                      ],
                    ),
                  ),
                  onTap: () => print("ttttttttt"),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
                GestureDetector(
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                    ),
                    child: Row(
                      children: [
                        const Icon(Icons.phone),
                        const SizedBox(width: 10),
                        Text(
                          '手机号码',
                          style: Get.textTheme.titleMedium,
                        ),
                        Expanded(
                          child: Align(
                            alignment: Alignment.centerRight,
                            child: Text(
                              '${controller.userProfile.value.mobile}',
                              style: Get.textTheme.bodyMedium,
                            ),
                          ),
                        ),
                        // const SizedBox(width: 20),
                        const Icon(
                          Icons.keyboard_arrow_right,
                        )
                      ],
                    ),
                  ),
                  onTap: () => print("ttttttttt"),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
                GestureDetector(
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                    ),
                    child: Row(
                      children: [
                        const Icon(Icons.mail),
                        const SizedBox(width: 10),
                        Text(
                          '用户邮箱',
                          style: Get.textTheme.titleMedium,
                        ),
                        Expanded(
                          child: Align(
                            alignment: Alignment.centerRight,
                            child: Text(
                              '${controller.userProfile.value.email}',
                              style: Get.textTheme.bodyMedium,
                            ),
                          ),
                        ),
                        // const SizedBox(width: 20),
                        const Icon(
                          Icons.keyboard_arrow_right,
                        )
                      ],
                    ),
                  ),
                  onTap: () => print("ttttttttt"),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
                GestureDetector(
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                    ),
                    child: Row(
                      children: [
                        Icon(
                          controller.userProfile.value.sex == null
                              ? Icons.person
                              : controller.userProfile.value.sex == 1
                                  ? Icons.man
                                  : Icons.woman,
                        ),
                        const SizedBox(width: 10),
                        Text(
                          '性别',
                          style: Get.textTheme.titleMedium,
                        ),
                        Expanded(
                          child: Align(
                            alignment: Alignment.centerRight,
                            child: Text(
                              '${InitSystemDataUtil.getDictLabelByTypeAndValue(
                                DictTypeEnum.systemUserSex.type,
                                controller.userProfile.value.sex,
                              )}',
                              style: Get.textTheme.bodyMedium,
                            ),
                          ),
                        ),
                        // const SizedBox(width: 20),
                        const Icon(
                          Icons.keyboard_arrow_right,
                        )
                      ],
                    ),
                  ),
                  onTap: () => print("ttttttttt"),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
                GestureDetector(
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                    ),
                    child: Row(
                      children: [
                        const Icon(Icons.account_tree_outlined),
                        const SizedBox(width: 10),
                        Text(
                          '所属部门',
                          style: Get.textTheme.titleMedium,
                        ),
                        Expanded(
                          child: Align(
                            alignment: Alignment.centerRight,
                            child: Text(
                              '${controller.userProfile.value.dept?.name}',
                              style: Get.textTheme.bodyMedium,
                            ),
                          ),
                        ),
                        const Icon(null),
                      ],
                    ),
                  ),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
                GestureDetector(
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                    ),
                    child: Row(
                      children: [
                        const Icon(Icons.signpost_outlined),
                        const SizedBox(width: 10),
                        Text(
                          '所属岗位',
                          style: Get.textTheme.titleMedium,
                        ),
                        Expanded(
                          child: Align(
                            alignment: Alignment.centerRight,
                            child: Text(
                              '${controller.userProfile.value.posts?.map((e) => e.name).join("|")}',
                              style: Get.textTheme.bodyMedium,
                              maxLines: 1,
                              overflow: TextOverflow.ellipsis,
                            ),
                          ),
                        ),
                        const Icon(null),
                      ],
                    ),
                  ),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
                GestureDetector(
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                    ),
                    child: Row(
                      children: [
                        const Icon(Icons.calendar_month),
                        const SizedBox(width: 10),
                        Text(
                          '创建日期',
                          style: Get.textTheme.titleMedium,
                        ),
                        Expanded(
                          child: Align(
                            alignment: Alignment.centerRight,
                            child: Text(
                              '${controller.userProfile.value.createTime}',
                              style: Get.textTheme.bodyMedium,
                            ),
                          ),
                        ),
                        const Icon(null),
                      ],
                    ),
                  ),
                ),
                Divider(
                  height: 10,
                  color: Get.theme.primaryColorLight,
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
